﻿using System.Collections.Generic;
using CI.Models.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CI.Models.Tests
{
    [TestClass]
    public class DynamicBaseTests
    {
        [TestMethod]
        public void Dynamic_Property_Sets_And_Gets_Same_Instance()
        {
            dynamic d = new DynamicBase();

            object o = new object();

            d.obj = o;

            Assert.AreSame(o, d.obj);
        }

        [TestMethod]
        public void Dynamic_Property_Supports_Lists()
        {
            dynamic d = new DynamicBase();

            var objs = new List<object> {1, 2, 3, 4};

            d.objs = objs;
            Assert.IsNotNull(d.objs);
            Assert.AreEqual(4, d.objs.Count);
            Assert.AreEqual(3, d.objs[2]);
        }

        [TestMethod]
        public void Dynamic_Property_SetValue_Get()
        {
            dynamic d = new DynamicBase();

            var o = new object();

            d.SetValue("obj", o);

            Assert.AreSame(o, d.obj);
        }

        public class ListObject : DynamicBase
        {
            public List<int> Ints
            {
                get { return new List<int>(); }
            }
        }
    }
}